package com.surrey.p2p.view;

import java.awt.Color;
import java.awt.Paint;
import java.util.ArrayList;

import org.apache.commons.collections15.Transformer;

import com.surrey.p2p.model.CANNode;
import com.surrey.p2p.model.P2PNode;

public class VertexColourTransformer implements Transformer<CANNode, Paint> {
	ArrayList<P2PNode> busyNodes;
	ArrayList<P2PNode> destination;

	VertexColourTransformer(ArrayList<P2PNode> busyNodes, ArrayList<P2PNode> destination) {
		this.busyNodes = busyNodes;
		this.destination = destination;
	}

	@Override
	public Paint transform(CANNode arg0) {
		Color p = Color.LIGHT_GRAY;
		if (arg0.isOnline() == false) {
			p = Color.GRAY;
		}
		if (busyNodes.contains(arg0)) {
			p = Color.BLUE;
		}
		if (destination.contains(arg0)) {
			p = Color.ORANGE;
		}
		return p;
	}

}
